/**
  ******************************************************************************
  * @author     Chris
  * @since      2024/6/12 10:55
  *
  * @file       pd_gpio.h
  * @brief      Head file of GPIO peripheral driver.
  *
  * @note       This file contains the peripheral driver's function declaration
  *             for the GPIO.
  *
  * @warning    None.
  ******************************************************************************
  * Change Logs:
  *   Date           Author       Notes
  *   2024-06-12     Chris        the first version
  *
  ******************************************************************************
  */

#ifndef JLC_SKY_GPIO_H
#define JLC_SKY_GPIO_H

#include "stm32f407xx.h"
#include "drivers.h"

typedef struct GPIODef GPIO;
typedef struct GPIOListDef GPIOList;

struct GPIODef {
    GPIO_TypeDef *GPIOx;

    uint32_t Pin;
    uint32_t Mode;
    uint32_t Speed;
    uint32_t OutputType;
    uint32_t Pull;
    uint32_t Alternate;

    void (*init)(const GPIO *this);

    void (*setBit)(const GPIO *this);

    void (*resetBit)(const GPIO *this);

    void (*setOutMode)(const GPIO *this);

    void (*setInMode)(const GPIO *this);

    uint8_t (*getBit)(const GPIO *this);
};

extern const struct GPIOClass {
    GPIO *(*build)(GPIO_TypeDef *GPIOx, uint32_t Pin);
} GPIOBuilder;


struct GPIOListDef {
    GPIO **gpios;
    uint8_t gpioSize;

    void (*init)(const GPIOList *this);
};

extern const struct GPIOListClass {
    GPIOList *(*build)(GPIO **gpios, uint8_t gpioSize);
} GPIOListBuilder;

#endif //JLC_SKY_GPIO_H
